package org.jeecg.modules.demo.utils;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

/**
 * 日期操作辅助类
 *
 * @author 刘威
 *
 */
public class DateUtil {

	private static Log log = LogFactory.getLog(DateUtil.class);
	/**
	 * 默认日期格式
	 */
	private static final String FULL_FORMAT = "yyyyMMddHHmmss";
	private static final String LONG_FORMAT = "yyyy-MM-dd HH:mm:ss";
	private static final String SHORT_FORMAT = "yyyy-MM-dd";
	private static final String TIME_FORMAT = "HH:mm:ss";
	private static final String YMD_FORMAT = "yyyy年MM月dd日";
	private static final String CODE_FORMAT = "yyyyMMdd";
	private static final String YEAR_FORMAT = "yyyy";
	private static final String MONTH_FORMAT = "MM";
	private static final String DAY_FORMAT = "DD";
	private static final String YM_FORMAT = "yyyy-MM";
	/**
	 * 默认日期格式化对象
	 */
	private static final SimpleDateFormat LONG_DATE_FORMAT = new SimpleDateFormat(LONG_FORMAT);
	private static final SimpleDateFormat SHORT_DATE_FORMAT = new SimpleDateFormat(SHORT_FORMAT);
	private static final SimpleDateFormat YEAR_MONTH_FORMAT = new SimpleDateFormat(YM_FORMAT);
	/**
	 * 每日毫秒常数
	 */
	private static final int DAY_MILLSECONDS = 1000 * 60 * 60 * 24;
	/**
	 * 月份信息参数数组
	 */
	private static final String[] MONTH = { Configuration.JANUARY, Configuration.FEBRUARY, Configuration.MARCH,
			Configuration.April, Configuration.MAY, Configuration.JUNE, Configuration.JULY, Configuration.AUGUST,
			Configuration.SEPTEMPBER, Configuration.OCTOBER, Configuration.NOVEMBER, Configuration.DECEMBER };
	/**
	 * 星期信息参数数组
	 */
	private static final String[] WEEK = { Configuration.SUNDAY, Configuration.MONDAY, Configuration.TUESDAY,
			Configuration.WEDNESDAY, Configuration.THURSDAY, Configuration.FRIDAY, Configuration.SATURDAY };
	public static final String START_TIME = " 00:00:00";
	public static final String END_TIME = " 23:59:59";

	public static String getCurrentMonthStartDate() {
		String ret = null;
		try {
			ret = fomatCodeShortNow(getMonthStartDate(new Date()));
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return ret;
	}

	public static String getCurrentMonthEndDate() {
		String ret = null;
		try {
			ret = fomatCodeShortNow(getMonthEndDate(new Date()));
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return ret;
	}

	public static String getNextMonthEndDate() {
		String ret = null;
		try {
			Date nextMonthdate = getNextMonthDate(new Date());
			ret = fomatCodeShortNow(getMonthEndDate(nextMonthdate));
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return ret;
	}

	public static String getCurrentYearStartDate() {
		String ret = null;
		try {
			ret = fomatCodeShortNow(getYearStartDate(new Date()));
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return ret;
	}

	public static String getCurrentYearEndDate() {
		String ret = null;
		try {
			ret = fomatCodeShortNow(getYearEndDate());
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return ret;
	}

	public static String fomatCodeShortNow() {
		String ret = null;
		try {
			ret = fomatCodeShortNow(new Date());
		} catch (Exception e) {
			e.printStackTrace();
		}
		return ret;
	}

	public static String fomatCodeShortNow(Date date) {
		String ret = null;
		try {
			ret = formatDate(date, SHORT_FORMAT);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return ret;
	}

	public static String fomatCodeShortYMNow(Date date) {
		String ret = null;
		try {
			ret = formatDate(date, YM_FORMAT);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return ret;
	}

	public static String fomatCodeTimeNow() {
		String ret = null;
		try {
			ret = formatDate(new Date(), TIME_FORMAT);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return ret;
	}

	/**
	 * 将当前日期转换成Date对象，默认参数日期格式为短日期格式
	 *
	 * @return
	 */
	public static Date getShortFormatNow() {
		Date ret = null;
		try {
			ret = getShortFormatDate(fomatShortNow());
		} catch (Exception e) {
			e.printStackTrace();
		}
		return ret;
	}

	/**
	 * 将当前年份四位字符串
	 *
	 * @return
	 */
	public static String fomatYearNow() {
		String ret = null;
		try {
			ret = formatDate(new Date(), YEAR_FORMAT);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return ret;
	}

	/**
	 * 将当前月份两位字符串
	 *
	 * @return
	 */
	public static String fomatMonthNow() {
		String ret = null;
		try {
			ret = formatDate(new Date(), MONTH_FORMAT);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return ret;
	}

	/**
	 * 把参数转换成Date对象，默认参数日期格式为短日期格式
	 *
	 * @param dateString
	 *            格式化日期字符串
	 * @return
	 */
	public static Date getShortFormatDate(String dateString) {
		Date ret = null;
		try {
			ret = SHORT_DATE_FORMAT.parse(dateString);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return ret;
	}

	/**
	 * 把参数转换成Date对象，默认参数日期格式为短日期格式
	 *
	 * @param dateString
	 *            格式化日期字符串
	 * @return
	 */
	public static Date getYearMonthFormatDate(String dateString) {
		Date ret = null;
		try {
			ret = YEAR_MONTH_FORMAT.parse(dateString);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return ret;
	}

	/**
	 * 把参数转换成Date对象，默认参数日期格式为短日期格式
	 *
	 * @param dateString
	 *            格式化日期字符串
	 * @return
	 */
	public static String getYMDFormatString(String dateString) {
		String ret = null;
		try {
			ret = new SimpleDateFormat(YMD_FORMAT).format(getShortFormatDate(dateString));

		} catch (Exception e) {
			e.printStackTrace();
		}

		return ret;
	}

	/**
	 * 将当前日期转换成Date对象，默认参数日期格式为长日期格式
	 *
	 * @return
	 */
	public static Date getLongFormatNow() {
		Date ret = null;
		try {
			ret = getLongFormatDate(formatLongNow());
		} catch (Exception e) {
			e.printStackTrace();
		}
		return ret;
	}

	/**
	 * 把参数转换成Date对象，默认参数日期格式为长日期格式
	 *
	 * @param dateString
	 *            格式化日期字符串
	 * @return
	 */
	public static Date getLongFormatDate(String dateString) {
		Date ret = null;
		try {
			ret = LONG_DATE_FORMAT.parse(dateString);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return ret;
	}

	/**
	 * 把参数转换成Date对象，参数日期格式需要设置
	 *
	 * @param dateString
	 *            格式化日期字符串
	 * @param formatType
	 *            格式化格式
	 * @return
	 */
	public static Date getFormatDate(String dateString, String formatType) {
		Date ret = null;
		try {
			if (dateString == null || dateString.equals("") || formatType == null || formatType.equals("")) {
				return new Date();
			}
			ret = new SimpleDateFormat(formatType).parse(dateString);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return ret;
	}

	/**
	 * 把当前日期转换成短日期格式字符串
	 *
	 * @return
	 */
	public static String fomatShortNow() {
		String ret = null;
		try {
			ret = formatShortDate(new Date());
		} catch (Exception e) {
			e.printStackTrace();
		}
		return ret;
	}

	/**
	 * 把日期对象转换成短日期格式字符串
	 *
	 * @param date
	 *            格式化日期
	 * @return
	 */
	public static String formatShortDate(Date date) {
		String ret = null;
		try {
			ret = formatDate(date, SHORT_FORMAT);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return ret;
	}

	public static String fomatCodeNow() {
		String ret = null;
		try {
			ret = formaNumbertDate(new Date());
		} catch (Exception e) {
			e.printStackTrace();
		}
		return ret;
	}

	public static String formaNumbertDate(Date date) {
		String ret = null;
		try {
			ret = formatDate(date, CODE_FORMAT);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return ret;
	}

	public static String formaFullNumbertDate(Date date) {
		String ret = null;
		try {
			ret = formatDate(date, FULL_FORMAT);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return ret;
	}

	public static String formatCodeDate(Date date) {
		String ret = null;
		try {
			ret = formatDate(date, SHORT_FORMAT);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return ret;
	}

	/**
	 * 把当前日期转换成长日期格式字符串
	 *
	 * @return
	 */
	public static String formatLongNow() {
		String ret = null;
		try {
			ret = formatLongDate(new Date());
		} catch (Exception e) {
			e.printStackTrace();
		}
		return ret;
	}

	/**
	 * 把日期对象转换成长日期格式字符串
	 *
	 * @param date
	 *            格式化日期
	 * @return
	 */
	public static String formatLongDate(Date date) {
		String ret = null;
		try {
			ret = formatDate(date, LONG_FORMAT);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return ret;
	}

	/**
	 * 把日期对象转换成指定日期格式字符串
	 *
	 * @param date
	 *            格式化日期
	 * @param formatType
	 *            格式化格式
	 * @return
	 */
	public static String formatDate(Date date, String formatType) {
		String ret = null;
		try {
			if (date == null || formatType == null || formatType.equals("")) {
				return ret;
			}
			ret = new SimpleDateFormat(formatType).format(date);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return ret;
	}

	/**
	 * 获取date days之后的日期（days为负数即为该日期days之前）
	 *
	 * @param date
	 * @param days
	 * @return
	 */
	public static Date generateDateOfDays(Date date, int days) {
		Date ret = null;
		try {
			if (date == null) {
				return ret;
			}
			Calendar calendar = Calendar.getInstance();
			calendar.setTime(date);
			calendar.add(Calendar.DAY_OF_MONTH, days);
			ret = calendar.getTime();

		} catch (Exception e) {
			e.printStackTrace();
		}
		return ret;
	}

	/**
	 * 计算日期之间的相隔天数
	 *
	 * @param early
	 * @param late
	 * @return
	 */
	public static long calculateDaysBetween(Date early, Date late) {
		long ret = 0;
		try {
			if (early == null && late == null) {
				return ret;
			}
			ret = ((late.getTime() - early.getTime()) / DAY_MILLSECONDS);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return ret;
	}

	/**
	 * 判定指定日期是否在当期日期指定天数之前
	 *
	 * @param early
	 * @param day
	 * @return
	 */
	public static boolean isBeforeNow(Date early, int day) {
		boolean ret = false;
		try {
			ret = isBeforeDate(early, new Date(), day);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return ret;
	}

	/**
	 * 判定early日期是否在late日期指定天数之前
	 *
	 * @param early
	 * @param late
	 * @param day
	 *            相隔天数
	 * @return
	 */
	public static boolean isBeforeDate(Date early, Date late, int day) {
		boolean ret = false;
		try {
			if (early == null || late == null) {
				return ret;
			}
			Calendar calendar = Calendar.getInstance();
			calendar.setTime(late);
			calendar.add(Calendar.DAY_OF_MONTH, -day);
			ret = early.before(calendar.getTime());
		} catch (Exception e) {
			e.printStackTrace();
		}
		return ret;
	}

	/**
	 * 判定指定日期是否在当前日期指定天数之后
	 *
	 * @param late
	 * @param day
	 * @return
	 */
	public static boolean isAfterNow(Date late, int day) {
		boolean ret = false;
		try {
			ret = isAfterDate(new Date(), late, day);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return ret;
	}

	/**
	 * 判定late日期是否在early日期指定天数之后
	 *
	 * @param early
	 * @param late
	 * @param day
	 *            相隔天数
	 * @return
	 */
	public static boolean isAfterDate(Date early, Date late, int day) {
		boolean ret = false;
		try {
			if (early == null || late == null) {
				return ret;
			}
			Calendar calendar = Calendar.getInstance();
			calendar.setTime(early);
			calendar.add(Calendar.DAY_OF_MONTH, day);
			ret = late.after(calendar.getTime());
		} catch (Exception e) {
			e.printStackTrace();
		}
		return ret;
	}

	/**
	 * 获取当期日期星期信息参数
	 *
	 * @return
	 */
	public static String getNowWeek() {
		String ret = null;
		try {
			ret = getDateWeek(new Date());
		} catch (Exception e) {
			e.printStackTrace();
		}
		return ret;
	}

	/**
	 * 获取指定日期星期信息参数
	 *
	 * @param date
	 * @return
	 */
	public static String getDateWeek(Date date) {
		String ret = null;
		try {
			if (date == null) {
				return ret;
			}
			Calendar calendar = Calendar.getInstance();
			calendar.setTime(date);
			ret = WEEK[calendar.get(Calendar.DAY_OF_WEEK) - 1];
		} catch (Exception e) {
			e.printStackTrace();
		}
		return ret;
	}

	/**
	 * 获取当期日期月份中文信息参数
	 *
	 * @return
	 */
	public static String getNowMonth() {
		String ret = null;
		try {
			ret = getDateMonth(new Date());
		} catch (Exception e) {
			e.printStackTrace();
		}
		return ret;
	}

	/**
	 * 获取指定日期月份中文信息参数
	 *
	 * @param date
	 * @return
	 */
	public static String getDateMonth(Date date) {
		String ret = null;
		try {
			if (date == null) {
				return ret;
			}
			Calendar calendar = Calendar.getInstance();
			calendar.setTime(date);
			ret = MONTH[calendar.get(Calendar.MONTH)];
		} catch (Exception e) {
			e.printStackTrace();
		}
		return ret;
	}

	/**
	 * 获取当前日期上一年信息参数
	 *
	 * @return
	 */
	public static Date getLastYearNow() {
		Date ret = null;
		try {
			ret = getLastYearDate(new Date());
		} catch (Exception e) {
			e.printStackTrace();
		}
		return ret;
	}

	/**
	 * 获取指定日期上一年信息参数
	 *
	 * @param date
	 * @return
	 */
	public static Date getLastYearDate(Date date) {
		Date ret = null;
		try {
			if (date == null) {
				return ret;
			}
			Calendar calendar = Calendar.getInstance();
			calendar.setTime(date);
			calendar.add(Calendar.YEAR, -1);
			ret = calendar.getTime();
		} catch (Exception e) {
			e.printStackTrace();
		}
		return ret;
	}

	/**
	 * 获取当前日期下一年信息参数
	 *
	 * @return
	 */
	public static Date getNextYearNow() {
		Date ret = null;
		try {
			ret = getNextYearDate(new Date());
		} catch (Exception e) {
			e.printStackTrace();
		}
		return ret;
	}

	/**
	 * 获取指定日期下一年信息参数
	 *
	 * @param date
	 * @return
	 */
	public static Date getNextYearDate(Date date) {
		Date ret = null;
		try {
			if (date == null) {
				return ret;
			}
			Calendar calendar = Calendar.getInstance();
			calendar.setTime(date);
			calendar.add(Calendar.YEAR, 1);
			ret = calendar.getTime();
		} catch (Exception e) {
			e.printStackTrace();
		}
		return ret;
	}

	/**
	 * 获取当期日期上一月信息参数
	 *
	 * @return
	 */
	public static Date getLastMonthNow() {
		Date ret = null;
		try {
			ret = getLastMonthDate(new Date());
		} catch (Exception e) {
			e.printStackTrace();
		}
		return ret;
	}

	/**
	 * 获取指定日期上一月信息参数
	 *
	 * @param date
	 * @return
	 */
	public static Date getLastMonthDate(Date date) {
		Date ret = null;
		try {
			if (date == null) {
				return ret;
			}
			Calendar calendar = Calendar.getInstance();
			calendar.setTime(date);
			calendar.add(Calendar.MONTH, -1);
			ret = calendar.getTime();
		} catch (Exception e) {
			e.printStackTrace();
		}
		return ret;
	}

	/**
	 * 获取当前日期下一月信息参数
	 *
	 * @return
	 */
	public static Date getNextMonthNow() {
		Date ret = null;
		try {
			ret = getNextMonthDate(new Date());
		} catch (Exception e) {
			e.printStackTrace();
		}
		return ret;
	}

	/**
	 * 获取指定日期下一月信息参数
	 *
	 * @param date
	 * @return
	 */
	public static Date getNextMonthDate(Date date) {
		Date ret = null;
		try {
			if (date == null) {
				return ret;
			}
			Calendar calendar = Calendar.getInstance();
			calendar.setTime(date);
			calendar.add(Calendar.MONTH, 1);
			ret = calendar.getTime();
		} catch (Exception e) {
			e.printStackTrace();
		}
		return ret;
	}

	/**
	 * 获取当前日期前一天信息参数
	 *
	 * @return
	 */
	public static Date getLastDayNow() {
		Date ret = null;
		try {
			ret = getLastDayDate(new Date());
		} catch (Exception e) {
			e.printStackTrace();
		}
		return ret;
	}

	/**
	 * 获取指定日期前一天信息参数
	 *
	 * @param date
	 * @return
	 */
	public static Date getLastDayDate(Date date) {
		Date ret = null;
		try {
			if (date == null) {
				return ret;
			}
			Calendar calendar = Calendar.getInstance();
			calendar.setTime(date);
			calendar.add(Calendar.DAY_OF_MONTH, -1);
			ret = calendar.getTime();
		} catch (Exception e) {
			e.printStackTrace();
		}
		return ret;
	}

	/**
	 * 获取当前日期下一天信息参数
	 *
	 * @return
	 */
	public static Date getNextDayNow() {
		Date ret = null;
		try {
			ret = getNextDayDate(new Date());
		} catch (Exception e) {
			e.printStackTrace();
		}
		return ret;
	}

	/**
	 * 获取指定日期下一天信息参数
	 *
	 * @param date
	 * @return
	 */
	public static Date getNextDayDate(Date date) {
		Date ret = null;
		try {
			if (date == null) {
				return ret;
			}
			Calendar calendar = Calendar.getInstance();
			calendar.setTime(date);
			calendar.add(Calendar.DAY_OF_MONTH, 1);
			ret = calendar.getTime();
		} catch (Exception e) {
			e.printStackTrace();
		}
		return ret;
	}

	/**
	 * 获取当前日期所在月份天数
	 *
	 * @return
	 */
	public static int getDaysOfMonthNow() {
		return getDaysOfMonth(new Date());
	}

	/**
	 * 获取指定日期所在月份天数
	 *
	 * @param date
	 * @return
	 */
	public static int getDaysOfMonth(Date date) {
		int ret = 0;
		try {
			if (date == null) {
				return ret;
			}
			Calendar calendar = Calendar.getInstance();
			calendar.setTime(date);
			ret = calendar.getActualMaximum(Calendar.DAY_OF_MONTH);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return ret;
	}

	/**
	 * 获取指定日期所在年份天数
	 *
	 * @param date
	 * @return
	 */
	public static int getDaysOfYear(Date date) {
		int ret = 0;
		try {
			if (date == null) {
				return ret;
			}
			Calendar calendar = Calendar.getInstance();
			calendar.setTime(date);
			ret = calendar.getActualMaximum(Calendar.DAY_OF_YEAR);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return ret;
	}

	/**
	 * 获取当前日期所在星期星期一日期信息参数
	 *
	 * @return
	 */
	public static Date getNowWeekStartDate() {
		return getWeekStartDate(new Date());
	}

	/**
	 * 获取指定日期所在星期星期一日期信息参数
	 *
	 * @param date
	 * @return
	 */
	public static Date getWeekStartDate(Date date) {
		Date ret = null;
		try {
			if (date == null) {
				return ret;
			}

			Calendar calendar = Calendar.getInstance();
			calendar.setTime(date);

			int weekDay = calendar.get(Calendar.DAY_OF_WEEK) - 1;
			switch (weekDay) {
			case 0:
				calendar.add(Calendar.DAY_OF_MONTH, -6);
				break;
			case 1:
				break;
			default:
				calendar.add(Calendar.DAY_OF_MONTH, -(weekDay - 1));
			}

			ret = calendar.getTime();
		} catch (Exception e) {
			e.printStackTrace();
		}
		return ret;
	}

	/**
	 * 获取当前日期所在星期星期日日期信息参数
	 *
	 * @return
	 */
	public static Date getNowWeekEndDate() {
		return getWeekEndDate(new Date());
	}

	/**
	 * 获取指定日期所在星期星期日日期信息参数
	 *
	 * @param date
	 * @return
	 */
	public static Date getWeekEndDate(Date date) {
		Date ret = null;
		try {
			if (date == null) {
				return ret;
			}

			Calendar calendar = Calendar.getInstance();
			calendar.setTime(date);

			int weekDay = calendar.get(Calendar.DAY_OF_WEEK) - 1;
			switch (weekDay) {
			case 0:
				break;
			default:
				calendar.add(Calendar.DAY_OF_MONTH, (7 - weekDay));
			}

			ret = calendar.getTime();
		} catch (Exception e) {
			e.printStackTrace();
		}
		return ret;
	}

	/**
	 * 获取当前日期所在月份第一日日期信息参数
	 *
	 * @return
	 */
	public static Date getNowMonthStartDate() {
		return getMonthStartDate(new Date());
	}

	/**
	 * 获取指定日期所在月份第一日日期信息参数
	 *
	 * @param date
	 * @return
	 */
	public static Date getMonthStartDate(Date date) {
		Date ret = null;
		try {
			if (date == null) {
				return ret;
			}

			Calendar calendar = Calendar.getInstance();
			calendar.setTime(date);
			calendar.set(Calendar.DAY_OF_MONTH, 1);

			ret = calendar.getTime();
		} catch (Exception e) {
			e.printStackTrace();
		}
		return ret;
	}

	/**
	 * 获取当前日期所在月份最末一日日期信息参数
	 *
	 * @return
	 */
	public static Date getNowMonthEndDate() {
		return getMonthEndDate(new Date());
	}

	/**
	 * 获取指定日期所在月份最末一日日期信息参数
	 *
	 * @param date
	 * @return
	 */
	public static Date getMonthEndDate(Date date) {
		Date ret = null;
		try {
			if (date == null) {
				return ret;
			}

			Calendar calendar = Calendar.getInstance();
			calendar.setTime(date);
			calendar.set(Calendar.DAY_OF_MONTH, getDaysOfMonth(date));

			ret = calendar.getTime();
		} catch (Exception e) {
			e.printStackTrace();
		}
		return ret;
	}

	/**
	 * 获取指定日期所在年份第一日日期信息参数
	 *
	 * @param date
	 * @return
	 */
	public static Date getYearStartDate(Date date) {
		Date ret = null;
		try {
			if (date == null) {
				return ret;
			}

			Calendar calendar = Calendar.getInstance();
			calendar.setTime(getNextYearDate(date));
			calendar.set(Calendar.DAY_OF_YEAR, 1);

			ret = calendar.getTime();
		} catch (Exception e) {
			e.printStackTrace();
		}
		return ret;
	}

	/**
	 * 获取指定日期所在年份最末一日日期信息参数
	 *
	 * @param date
	 * @return
	 */
	public static Date getYearEndDate(Date date) {
		Date ret = null;
		try {
			if (date == null) {
				return ret;
			}
			Date nextYeardate = getNextYearDate(date);
			Calendar calendar = Calendar.getInstance();
			calendar.setTime(nextYeardate);
			calendar.set(Calendar.DAY_OF_YEAR, getDaysOfYear(nextYeardate));

			ret = calendar.getTime();
		} catch (Exception e) {
			e.printStackTrace();
		}
		return ret;
	}

	/**
	 * 获取当前日期所在年份最末一日日期信息参数
	 *
	 * @param date
	 * @return
	 */
	public static Date getYearEndDate() {
		Date ret = null;
		try {
			Calendar calendar = Calendar.getInstance();
			calendar.setTime(new Date());
			calendar.set(Calendar.DAY_OF_YEAR, getDaysOfYear(new Date()));
			ret = calendar.getTime();
		} catch (Exception e) {
			e.printStackTrace();
		}
		return ret;
	}

	/**
	 * 计算相差天数
	 *
	 * @param date
	 * @return
	 */
	public static long getIntervalDays(String dateStr) {
		Calendar c1 = Calendar.getInstance();
		c1.setTime(DateUtil.getShortFormatDate(dateStr));

		Calendar c2 = Calendar.getInstance();
		c2.setTime(new Date());

		long l1 = c1.getTimeInMillis();
		long l2 = c2.getTimeInMillis();
		// 计算天数
		long days = (l2 - l1) / (24 * 60 * 60 * 1000);
		return days;
	}

	public static void main(String[] args) {
		// log.info(DateUtil.calculateDaysBetween(DateUtil.generateDateOfDays(
		// Calendar.getInstance().getTime(), 3), Calendar.getInstance()
		// .getTime()));
		// System.out.println(getCurrentMonthStartDate());
		System.out.println(getCurrentMonthEndDate());
		System.out.println(getNextMonthEndDate());
	}
}
